# 导入requests模块
import requests
"""
# 发送请求
resp = requests.get('http://www.baidu.com')
print(resp)
# 获取响应文本形式内容
print(resp.text)

resp = requests.get('http://httpbin.org/get')
print(resp)
# 获取响应的JSON，自动将JSON转为python数据（反序列化）
print(resp.json())
"""
url = 'https://p0.pipi.cn/mediaplus/friday_image_fe/cdf05c1425cea401e84a18cada94e2f5aa82f.jpeg?imageView2/1/w/464/h/644'
resp = requests.get(url)
print(resp)
# 获取二进制数据
print(resp.content)
# 二进制打开文件1.jpg，将读取的二进制数据写入到文件
with open('1.jpg', mode='wb') as fw:
    fw.write(resp.content)

